package com.web;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.LeaveDTO;
import bizlogic.LeaveManager;
import bizlogic.UserManager;

/**
 * @Thiri
 * Servlet implementation class DetailLeaveViewStaffServlet
 */
@WebServlet("/DetailLeaveViewStaffServlet")
public class DetailLeaveViewStaffServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DetailLeaveViewStaffServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doProcess(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doProcess(request, response);
	}
	
	protected void  doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	    String id = request.getParameter("id"); 
		/*UserManager um = new UserManager();
		LeaveManager lm=new LeaveManager();
		UserDTO manager = um.findUser(id);
		ArrayList<LeaveDTO> data = new ArrayList<LeaveDTO>();
		
		data = um.findAllLeaveByManagerId(manager);*/
	     
	    LeaveManager lm = new LeaveManager();
		LeaveDTO data = lm.findLeaveDetailByID(id);
		
		
	    request.setAttribute("user", data);
		RequestDispatcher rd = request.getRequestDispatcher("DetailLeaveApplicationStaff.jsp");
		rd.forward(request, response);
		
}

}
